Release 10.1A: OpenEdge Development:
Progress 4GL Handbook
Transaction blocks
Transactions in Progress are scoped to blocks. You’re already familiar with the concept of building procedures up out of nested blocks of procedural statements and how record scoping is affected by those blocks. Transaction scoping works in much the same way and is closely tied to the scoping of records to blocks. Some blocks in Progress procedures are transaction blocks and some aren’t, according to these rules:
- You can explicitly include the
TRANSACTIONkeyword on aFOR EACHorREPEATblock, or on aDOblock with the optional error-handling phrase beginningON ERROR. Any block that uses theTRANSACTIONkeyword becomes a transaction block.- Any block that directly updates the database or directly reads records with
EXCLUSIVE-LOCKlikewise becomes a transaction block. This can be a procedure block, a trigger block, or each iteration of aDO,FOR EACH, orREPEATblock.A direct database update can be, for example, a
CREATE,DELETE, orASSIGNstatement. A block is said to be directly reading records withEXCLUSIVE-LOCKif at least one of theFINDorFOR EACHstatements that has theEXCLUSIVE-LOCKkeyword is not embedded in an inner block enclosed within the block in question.A
DOblock without theNO-ERRORphrase does not automatically have the transaction property. Also, a procedure that would start a transaction on its own can run from another procedure that has already started a transaction. In this case, you enclose the called procedure in the larger transaction of the calling procedure. Once a transaction is started, all database changes are part of that transaction until it ends. Each user or session can have just one active transaction at a time. If one transaction block is nested within another, the inner block forms a subtransaction that you can programmatically undo if it causes an error or fails some validation constraint. You’ll learn about subtransactions later in Chapter 17, " Managing Transactions."
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |